import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int y = in.nextInt();
        int m = in.nextInt();
        int d = in.nextInt();
        int sum = 0;
        int[] month = {31,59,90,120,151,181,212,243,273,304,334,365};
        if (m >= 2) sum += month[m - 2];
        sum += d;
        if (m > 2) {
            if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) {
                sum++;
            }
        }
        System.out.print(sum);
    }
}


